
import { getQuestionsApi, deleteQuestionsApi, addQuestionsApi, updateQuestionsApi} from '../../api/audit/index'
import { randomQuestionsApi} from "../../api/audit/text"
export const state = () => ({
    list: [],
    disabledForm: "",
    randomQuestion: [],
    index: 0,
})

export const mutations = {

    SET_STATUS(state, payload) {
        state.disabledForm = payload
    },
    SET_RANDOM_QUESTIONS(state, data) {
        state.randomQuestion = data
    },
    SET_INDEX(state, index) {
        state.index = index
    }
}

export const actions = {

    // 随机获取20道题
    async randomQuestionDataFn({ commit }) {
        const r = await randomQuestionsApi()
        commit("SET_RANDOM_QUESTIONS", r.data);
    },
}

export const getters = {
    getterCurrentQuestion(state) {
        // console.log(state.randomQuestion[state.index]);
        return state.randomQuestion[state.index];
    }
}